﻿using System;
using System.Collections.Generic;

namespace WeiTap.Validator.Result
{
    [Serializable]
    public class ValidationFailure
    {
        public string PropertyName { get; set; }
        public string ErrorMessage { get; set; }
        /// <summary>
        /// 触发错误的属性值
        /// </summary>
        public object AttemtedValue { get; private set; }
        public object CustomState { get; set; }
        public Severity Severity { get; set; }
        public string ErrorCode { get; set; }
        /// <summary>
        /// Value {0} that you entered should be {1}
        /// </summary>
        public object[] FormattedMessageArguments { get; set; }
        /// <summary>
		/// Gets or sets the formatted message placeholder values.
		/// Similar placeholders are defined in fluent validation library (check documentation)
		/// </summary>
		public Dictionary<string, object> FormattedMessagePlaceholderValues { get; set; }

        /// <summary>
        /// The resource name used for building the message
        /// </summary>
        public string ResourceName { get; set; }
        public override string ToString()
        {
            return ErrorMessage;
        }
        public ValidationFailure() { }
        public ValidationFailure(string propertyName, string error)
            : this(propertyName, error, null)
        {

        }
        public ValidationFailure(string propertyName, string error, object attemptedValue)
        {
            this.PropertyName = propertyName;
            this.ErrorMessage = error;
            this.AttemtedValue = attemptedValue;
        }
    }
    /// <summary>
    /// 错误级别
    /// </summary>
    public enum Severity
    {
        /// <summary>
        /// 错误
        /// </summary>
        Error,
        /// <summary>
        /// 警告
        /// </summary>
        Warning,
        /// <summary>
        /// 信息
        /// </summary>
        Info
    }
}